package cn.kgc.ssm.service.impl;

import cn.kgc.ssm.commons.ResponseResult;
import cn.kgc.ssm.mapper.ActiveMapper;
import cn.kgc.ssm.mapper.JobMapper;
import cn.kgc.ssm.mapper.MemberMapper;
import cn.kgc.ssm.mapper.MessageMapper;
import cn.kgc.ssm.service.EchartsService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author 课工场
 * @date 2024/5/21
 * @description
 */
@Service
public class EchartsServiceImpl implements EchartsService {


    @Resource
    private MemberMapper  memberMapper;

    @Resource
    private ActiveMapper activeMapper;

    @Resource
    private MessageMapper messageMapper;

    @Resource
    private JobMapper jobMapper;

    @Override
    public ResponseResult panelData() {

        // 一个月的新会员数量
        Long  memberNumber =  memberMapper.selectPanelData();

        // 一周的新活动数量
        Long  activeNumber = activeMapper.selectPanelData();

        //一周新留言
        Long  messageNumber = messageMapper.selectPanelData();

        // 一个月的新岗位数量
        Long  jobNumber = jobMapper.selectPanelData();


        HashMap<String, Object> panelData = new HashMap<>();
        panelData.put("memberNumber",memberNumber);
        panelData.put("activeNumber",activeNumber);
        panelData.put("messageNumber",messageNumber);
        panelData.put("jobNumber",jobNumber); // {key:value,k:v}

        return ResponseResult.success().data(panelData);
    }

    @Override
    public ResponseResult lineData() {

        List<Map<String,Integer> >  result =  memberMapper.selectLineData();

        return ResponseResult.success().data(result);
    }
}
